<script>
function loadImage(url, cb/* callback */) {
  const img = document.createElement('img')
  img.src = url
  img.onload = () => cb(undefined, img)
  img.onerror = (e) => cb(['载入错误', e])
}
let url = 'https://tva1.sinaimg.cn/lrge/008i3skNgy1gvzs6fhdomj30p00dw0tq.jpg'
loadImage(url, (error, img) => {
  if (error) {
    console.log(error)
  } else {
    document.body.append(img)
  }
})

</script>